/**
 * Mermaid.js-based diagram styles
 */
@use './mixins' as *;

main:has(.docusaurus-mermaid-container):not(:has(.dont_hide_secondary_bar)) {
  .table-of-contents__left-border:has(a.table-of-contents__link--active),
  .table-of-contents__link--active {
    display: none;
  }
}

@include dark {
  .document-concept-page {
    .nodeLabel {
      color: white !important;
    }
  }
}

main:has(.docusaurus-mermaid-container) {
  .docusaurus-mermaid-container * {
    font-size: .85rem !important;
  }
}

.custom-mermaid-layout {
  .docusaurus-mermaid-container {
    * {
      font-size: .85rem;
      transition: transform ease-in-out .2s;
    }

    svg {
      position: relative;
      top: 0;
      transform: translateX(0);
    }

    @include medium-up {
      svg {
        transform: scale(1.3);
        transform-origin: top left;
        margin-bottom: 400px;
        margin-right: 200px;
      }
    }

    @include large-up {
      svg {
        transform: scale(1.5);
        transform: translateX(-100px) scale(1.5);
        margin-bottom: 700px;
        margin-left: 50px;
      }
    }

    @include xlarge-up {
      svg {
        transform: translateX(-400px) scale(1.8);
        margin-bottom: 1200px;
        margin-left: 100px;
      }
    }
  }
}

.document-concept-page {
  .docusaurus-mermaid-container {
    @include medium-up {
      svg {
        margin-bottom: 120px;
      }
    }

    @include large-up {
      svg {
        margin-bottom: 240px;
      }
    }

    @include xlarge-up {
      svg {
        margin-bottom: 360px;
      }
    }
  }
}

.mermaid-loading-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100px;
  margin: 2rem 0;
  padding: 1rem;
  border: 1px dashed var(--ifm-color-primary-light);
  border-radius: 8px;
  background-color: var(--ifm-color-primary-lightest);
}

html[data-theme='dark'] .mermaid-loading-container {
  background-color: var(--ifm-color-primary-darkest);
  border-color: var(--ifm-color-primary-light);
}

.mermaid-loading {
  display: flex;
  align-items: center;
  color: var(--ifm-color-primary-dark);
}

html[data-theme='dark'] .mermaid-loading {
  color: var(--ifm-color-primary-light);
}

/* Subtle loading animation */
.mermaid-loading:before {
  content: '';
  width: 20px;
  height: 20px;
  margin-right: 10px;
  border-radius: 50%;
  border: 3px solid var(--ifm-color-primary-light);
  border-top-color: transparent;
  animation: mermaid-spinner 1s linear infinite;
}

@keyframes mermaid-spinner {
  to { transform: rotate(360deg); }
}

.mermaid-fallback-container {
  margin: 2rem 0;
  padding: 1rem;
}

.mermaid-fallback-image {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.mermaid-fallback-notice {
  font-style: italic;
  margin-bottom: 1rem;
}

/* Animation for the fallback image */
.mermaid-fallback-image {
  transition: transform 0.2s ease;
}

.mermaid-fallback-image:hover {
  transform: scale(1.01);
}

.mermaid-download-link {
  margin-top: 0.5rem;
  color: var(--ifm-color-secondary-darkest);

  i {
    margin-right: .3rem;
    &::before {
      color: var(--strapi-primary-600);
    }
  }
}

html[data-theme='dark'] .mermaid-download-link {
  color: var(--ifm-color-secondary-lighter);
}

.mermaid-download-link a {
  color: var(--ifm-color-primary);
  text-decoration: none;
}

.mermaid-download-link a:hover {
  text-decoration: underline;
}
